import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      '@': fileURLToPath(
        new URL('./src', import.meta.url)
      )
    }
  },
  server: {
    https: false, // 是否开启 https
    open: false, // 是否自动在浏览器打开
    cors: true, // 允许跨域
    port: 5173, // 端口号
    host: true,
    proxy: {
      '/prod-api': {
        // target: 'http://docs.feli.top:2473',
        target: 'http://192.168.220.134/prod-api/',
        changeOrigin: true,
        rewrite: (path) =>
          path.replace(/^\/prod-api/, '')
      }
      // "/file": {
      //   target: "http://wlt.feli.top:1024",
      //   changeOrigin: true,
      // }
    }
  },
  build: {
    minify: 'terser',
    rollupOptions: {
      external: [
        '/wasm/lz4/rs_lz4.js?url',
        '/wasm/imgConvert/img_convert.js?url'
      ]
    }
  }
})
